package com.t174.car.controller;

import com.t174.car.dao.CarCheliangBeanDao;
import com.t174.car.entity.CarCheliangBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/Cheliang")
@Scope("prototype")
public class CarCheliangController {
    @Autowired
    CarCheliangBeanDao carCheliangBeanDao;
    @RequestMapping("/tong")
    @ResponseBody
    public Map<String,List<Object>> queryGroupXioQu(){
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Map<String,List<Object>> map = new HashMap<>() ;
        List<CarCheliangBean> list = carCheliangBeanDao.tongjiCar();
        List<Object> list1 = new ArrayList<>() ;
        List<Object> list2 = new ArrayList<>() ;

        for(CarCheliangBean bean : list){
            list1.add(bean.getBrand()) ;
            list2.add(bean.getPinpaicount()) ;
        }

        map.put("xq",list1) ;
        map.put("xqc",list2) ;

        return map ;
    }

}
